import { defineConfig } from '@rsbuild/core';
import { pluginVue } from '@rsbuild/plugin-vue';
import AutoImport from 'unplugin-auto-import/rspack';
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers';
import AutoComponents from 'unplugin-vue-components/rspack';
import { pluginSass } from '@rsbuild/plugin-sass';

export default defineConfig({
	/* output: {
		filename: {
      		html: 'web.html',
    	},
		minify: false,
	}, */
	plugins: [
		pluginVue(),
		pluginSass(), // 支持 sass 语法
	],
	server: {
		open: false,
		port: 3000,
		htmlFallback: 'index', // 默认情况下，当请求满足以下条件且未找到对应资源时，会回退到 index.html
		proxy: {
			'/api': 'http://localhost:3000',
		},
	},
	tools: {
		rspack: {
			plugins: [
				AutoImport({
					resolvers: [
						ElementPlusResolver({
							importStyle: 'scss',
						}),
					],
					dts: false,
					// imports: ['vue'],
				}),
				AutoComponents({
					// 自动加载组件的目录配置, 默认的为 'src/components'
					dirs: ['src'],
					// 组件支持的文件后缀名
					// extensions: ['vue'],
					dts: false,
					resolvers: [
						ElementPlusResolver({
							importStyle: 'scss',
						}),
					],
				}),
			],
		},
	},
});
